1. Field of the Invention
The present invention relates generally to the data processing field, and more particularly, to a computer implemented method, system and computer program product for managing heuristic properties for controlling an optimization transformation in a compiler or in other heuristically controlled software in a data processing system.
2. Description of the Related Art
A compiler is a mechanism that translates a source code program that is written in a high-level, human-readable programming language, into an equivalent object code program that is in a machine language that can be executed by a computer. For each main source program and a number of additional source programs or subroutines, the compiler translates each statement in the programs into machine language equivalents. The output of the compiler is a plurality of object code programs corresponding to the input source code programs. A linker program then combines the object code programs created by the compiler (that is, supplies the interconnecting links between the program components) to create a single machine-executable program.
A number of compiler optimizations use heuristic values to control behavior, for example, a limit on the number of branches, a default unroll factor, etc. These heuristic values are usually tuned based on experience gathered from compiling benchmarks and other programs. In some cases, different heuristic values are chosen based on command-line options, for example, a different default unroll factor may be chosen depending on the target processor.
In addition to default values for heuristic properties, some command-line modifiers, such as requesting the generated code to be compact (i.e., to favor smaller size over faster code), require modifying or resetting certain heuristic values, for example, limiting unroll factors.
A current method for having each optimization transformation logically determine its defaults for heuristic properties has the advantage of encapsulating a default value choice within the transformation code. Doing so, however, has the disadvantage that it becomes more difficult to control multiple heuristic properties from a central location. As a result, any change in the policy of how these heuristic values are chosen for different cases needs to be handled every place in the code where these heuristic values are determined (and used). Adding functionality to the compiler that has a wide impact on multiple heuristic values, such as compact control or a new optimization level, can be quite cumbersome and error-prone due to the need to locate and update every heuristic property that might be affected by the new control.
An alternative solution for heuristic values is to contain all heuristic values in a central database (or data structure, similar to the idea of Java Properties—a class in the Java Development Kit for managing properties, which can be stored, dumped to a file and read back; and System properties—a specific subset which can be overridden through the −D command line option), and then update/modify them as appropriate when new optimization controls are added or modified. The disadvantage of this approach is the lack of encapsulation, that is, if any changes are made to the logic of a transformation that requires changing the defaults for its heuristic properties; the compiler writer needs to make sure that these changes are also reflected in the central database that manages these heuristics. A further disadvantage of a central database is that it adds overhead for accessing heuristic properties which may be accessed frequently. Although these values can be cached, doing so adds an unnecessary complexity to the code and requires the compiler writer to be aware of the caching.
There is, accordingly, a need for a mechanism for more efficiently managing heuristic properties for controlling an optimization transformation in a compiler or in other heuristically controlled software in a data processing system.